/******************************************************************************
 * The contents of this file are subject to the   JDI License  Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Initial Developer of the Original Code is 陈慧然. Portions created by 
 * 陈慧然 are Copyright 陈慧然.
 * All Rights Reserved.
 *
 *              Contact john_holen@163.com for licensing alternatives.
 *
 *****************************************************************************/


package org.peony.client.web.components.table;

import org.peony.client.web.components.WebComponents;
import org.peony.exceptions.RenderException;
import org.peony.tools.StringUtil;
/**
 *  
 *
 *  @author     陈慧然
 *  @version    Id: Table.java, v 0.000 Mar 18, 2008 2:08:48 PM 陈慧然 Exp
 */
public class Table extends WebComponents{
	private Caption title;
	private THead head;
	private TFoot foot;
	private TBody body;
	
	public String toStandardString() throws RenderException {
		if(StringUtil.isEmpty(getId()))
			throw new RenderException("Table (A Component) Can NOT has no id!");
		StringBuffer sb = new StringBuffer();
		sb.append("<table ").append("id= \"").append(getId()).append("\"")
			.append(StringUtil.isNotEmpty(getUIClass())?" class=\"" + getUIClass() + "\">" : ">");
		if(getTitle() != null){
			sb.append(getTitle().toStandardString());
		}
		if(getHead() != null){
			sb.append(getHead().toStandardString());
		}
		if(getFoot() != null){
			sb.append(getFoot().toStandardString());
		}
		if(getBody() != null){
			sb.append(getBody().toStandardString());
		}
		sb.append("</table>");
		return sb.toString();
	}
	
	public Caption getTitle() {
		return title;
	}

	public void setTitle(Caption title) {
		this.title = title;
	}

	public TFoot getFoot() {
		return foot;
	}

	public void setFoot(TFoot foot) {
		this.foot = foot;
	}

	public THead getHead() {
		return head;
	}

	public void setHead(THead head) {
		this.head = head;
	}

	public TBody getBody() {
		return body;
	}

	public void setBody(TBody body) {
		this.body = body;
	}
}
